package com.ncloud.common.utils;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

/**
 * Created by shiqiang on 2017/5/22.
 */
public class PageHelperUtils {
    private static final Logger logger = LogManager.getLogger(PageHelperUtils.class);
    public static void setPageParam(JSONObject json){
       // logger.info("分页参数信息111："+json.toJSONString());
        if(json.containsKey("pageNum") && json.containsKey("pageSize")){
           // logger.info("分页参数信息："+json.toJSONString());
            logger.info("pageSize="+json.getIntValue("pageSize"));
            PageHelper.startPage(json.getIntValue("pageNum"),json.getIntValue("pageSize"));
        }
    }

    public static boolean isPage(JSONObject json){
        if(json.containsKey("pageNum") && json.containsKey("pageSize")){
            return true;
        }else {
            return false;
        }
    }
}
